home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / DATABASE / NFLTPW11.ZIP / NFLTPW.PAS < prev    next >
Pascal/Delphi Source File  |  1993-07-12  |  42KB  |  1,361 lines

  1. Program NFLTPW;
  2. {$r nfltpw.res}
  3. uses WinTypes, WinProcs, WObjects, Printer,
  4.      win31,bitmap,Strings,stddlgs;
  5. const
  6.      MaxTeams = 28;
  7.      MaxGames = 14;
  8.      MaxWeeks = 18;
  9.      PlayerNameSize = 20;
  10.      ScoreFieldSize = 3;
  11.      TeamNameSize   = 25;
  12.      DLLName = 'NFLLIB.DLL';
  13.      em_DLLNotFound    = 1;
  14.      cm_PlayerMaint    = 102;
  15.      cm_DeletePlayers  = 103;
  16.      cm_DeleteSchedule = 104;
  17.      cm_EnterSchedule  = 105;
  18.      cm_EnterPicks     = 202;
  19.      cm_EnterScores    = 203;
  20.      cm_PrintSchedule  = 301;
  21.      cm_PrintResults   = 302;
  22.      cm_SetupPrinter   = 303;
  23.      cm_about          = 401;
  24.      id_AddPlayer      = 102;
  25.      id_DeletePlayer   = 103;
  26.      id_BoxMask        = 100;
  27.      id_ButtonMask     = 100;
  28.      id_TeamMask       = 200;
  29.      id_week           = 11;
  30.      id_PlayerCombo    = 12;
  31.      id_PickPoints     = 13;
  32.      id_PlayerBox      = 101;
  33.      id_Transparent    = 10;
  34. type
  35.     pMyDialog = ^tMyDialog;
  36.     tmyDialog = object(tDialog)
  37.     constructor init(aParent:pWindowsObject; aName:pChar);
  38.        procedure wmCtlColor(var Msg:tMessage);
  39.                  virtual wm_first + wm_CtlColor;
  40.     end;
  41.  
  42.     PickType = (Visitor,Home,None);
  43.  
  44.     tNFLApp = object(tApplication)
  45.         Lib: THandle;
  46.         constructor Init(AName: PChar);
  47.         destructor  done;   virtual;
  48.         procedure   InitMainWindow; virtual;
  49.         procedure   WritePlayerList; virtual;
  50.     end;
  51.  
  52.   pMyListBox = ^tMyListBox;
  53.   tmyListBox = object(tlistbox)
  54.     procedure wmVScroll(var msg:tmessage); virtual wm_first + wm_VScroll;
  55.   end;
  56.  
  57.   procedure tmylistbox.wmVScroll(var msg:tmessage);
  58.   begin
  59.      case msg.wparam of
  60.        sb_LineDown:
  61.           if GetSelIndex <> getcount then
  62.           begin
  63.                SetSelIndex(GetSelIndex + 1);
  64.                sendmessage(Parent^.hwindow,wm_command,getid,
  65.                            hwindow or (lbn_selchange shl 16));
  66.           end;
  67.        sb_LineUp  :
  68.           if GetSelIndex <> 0 then
  69.           begin
  70.                SetSelIndex(GetSelIndex - 1);
  71.                sendmessage(Parent^.hwindow,wm_command,getid,
  72.                            hwindow or (lbn_selchange shl 16));
  73.           end;
  74.      else DefWndProc(msg);
  75.      end;
  76.   end;
  77.  
  78. var NFLApp : tNFLApp;
  79.  
  80. constructor tmydialog.init(aParent:pWindowsObject; aName:pChar);
  81. begin
  82.      tdialog.init(aparent,aname);
  83. end;
  84.  
  85. type
  86.    ListRec = record
  87.        ListStrings : pStrCollection;
  88.        ListSelection : integer;
  89.    end;
  90.  
  91.    ComboRec = record
  92.         ComboStrings   : pStrCollection;
  93.         ComboSelection : array[0..20] of Char;
  94.    end;
  95.  
  96.    SchdTransferRec = record
  97.        STRWeek  : ListRec;
  98.        STRTeams : array[1..MaxTeams] of ComboRec;
  99.    end;
  100.  
  101.    TeamRec = record
  102.           Name  : array[0..PlayerNameSize] of char;
  103.           Score : array[0..3] of char;
  104.    end;
  105.  
  106.    Scores = record
  107.             Score : array [1..MaxGames,0..1] of byte;
  108.    end;
  109.  
  110.    Schedule = record
  111.               Team      : array [1..MaxGames,0..1] of byte;
  112.               GameScore : Scores
  113.    end;
  114.     PickData = record
  115.                GamePick : array [1..14] of word;
  116.                MNFScore : integer;
  117.     end;
  118.  
  119.     ResultData = record
  120.                  Wins,
  121.                  Losses,
  122.                  Ties,
  123.                  PtDiff : word;
  124.     end;
  125.  
  126.     Player = record
  127.              Name    : pchar;
  128.              PickRec : array [1..MaxWeeks] of PickData;
  129.              Results : array [1..MaxWeeks] of ResultData;
  130.     end;
  131.  
  132.     tPickRec = array [1..MaxWeeks] of PickData;
  133.     tResults = array [1..MaxWeeks] of ResultData;
  134.  
  135.     pPlayer = ^tPlayer;
  136.     tPlayer = object(tObject)
  137.               Name    : pchar;
  138.               PickRec : tPickRec;
  139.               Results : tResults;
  140.           constructor init(NewName    : pchar;
  141.                            NewPickRec : tPickRec;
  142.                            NewResults : tResults);
  143.           constructor Load(var s:tstream);
  144.           procedure Store(var s:tstream); virtual;
  145.           destructor Done; virtual;
  146.    end;
  147.  
  148.    tPlayerCollection = record
  149.       vs    : pstringcollection;
  150.       focus : word;
  151.     end;
  152.  
  153. const
  154.   rPlayer : tstreamrec = (
  155.             objtype : 150;
  156.             vmtlink: ofs(typeof(tplayer)^);
  157.             load : @tplayer.load;
  158.             store: @tplayer.store);
  159.  
  160.    constructor tPlayer.Init(NewName    : pchar;
  161.                            NewPickRec : tPickRec;
  162.                            NewResults : tResults);
  163.    begin
  164.         tobject.init;
  165.         Name    := NewName;
  166.         PickRec := NewPickRec;
  167.         Results := NewResults;
  168.    end;
  169.    constructor tplayer.load(var s:tstream);
  170.    begin
  171.         name := s.strread;
  172.         s.read(pickrec,sizeof(pickrec));
  173.         s.read(results,sizeof(results));
  174.    end;
  175.    procedure tplayer.store(var s:tstream);
  176.    begin
  177.         s.strwrite(Name);
  178.         s.write(PickRec,sizeof(PickRec));
  179.         s.write(Results,sizeof(Results));
  180.    end;
  181.    destructor tPlayer.done;
  182.    begin
  183.         StrDispose(Name);
  184.         tobject.done;
  185.    end;
  186. type
  187.     pStandings = ^tStandings;
  188.     tStandings = object(tObject)
  189.               Wins,
  190.               Losses,
  191.               Ties,
  192.               PtDiff  : word;
  193.               Name    : pchar;
  194.           constructor init(NewName    : pchar;
  195.                            NewWins,
  196.                            NewLosses,
  197.                            NewTies,
  198.                            NewPtDiff : word);
  199.           destructor Done; virtual;
  200.    end;
  201.    constructor tStandings.init(NewName    : pchar;
  202.                                NewWins,
  203.                                NewLosses,
  204.                                NewTies,
  205.                                NewPtDiff : word);
  206.    begin
  207.         tobject.init;
  208.         Name    := NewName;
  209.         Wins    := newwins;
  210.         Losses  := newlosses;
  211.         ties    := newties;
  212.         PtDiff  := newptdiff;
  213.    end;
  214.  
  215.    destructor tStandings.done;
  216.    begin
  217.         tobject.done;
  218.    end;
  219. type
  220.    pStandingsCollection = ^tStandingsCollection;
  221.    tStandingsCollection = object(tSortedCollection)
  222.        function KeyOf(Item:pointer): pointer; virtual;
  223.        function Compare(key1, key2: pointer):integer; virtual;
  224.    end;
  225.  
  226.    function tStandingsCollection.KeyOf(item:pointer): pointer;
  227.    begin
  228.         KeyOf := pstandings(item);
  229.    end;
  230.  
  231.    function tStandingsCollection.Compare(key1,key2:pointer):integer;
  232.    begin
  233.         if pstandings(key1)^.Wins < pstandings(key2)^.Wins
  234.         then compare := 1
  235.         else if pstandings(key1)^.Wins > pstandings(key2)^.Wins
  236.              then compare := -1
  237.              else if pstandings(key1)^.PtDiff > pstandings(key2)^.PtDiff
  238.                   then compare :=  1
  239.                   else compare := -1;
  240.    end;
  241.  
  242. type
  243.    pSchedule = ^tSchedule;
  244.    tSchedule = object(tObject)
  245.                ScheduleRec : Schedule;
  246.         constructor init(NewSchedule : Schedule);
  247.         constructor load(var s:tBufStream);
  248.         procedure   store(var s:tBufStream); virtual;
  249.         destructor  done; virtual;
  250.     end;
  251.  
  252.   pNumericEdit = ^tNumericEdit;
  253.   tNumericEdit = object(tEdit)
  254.     procedure wmchar(var Msg:tMessage);virtual Wm_first + wm_char;
  255.   end;
  256.  
  257.   pSchDialog = ^tSchDialog;
  258.   tSchDialog = object(tMyDialog)
  259.     sWeek : pMyListBox;
  260.     combo : array [1..MaxTeams] of pcombobox;
  261.     constructor init(aParent:pWindowsObject; aName:pChar);
  262.     procedure setupwindow; virtual;
  263.     procedure StoreSched;
  264.     procedure Ok(var Msg: TMessage);
  265.       virtual id_First + id_ok;
  266.     procedure HandleListBox(var Msg:tMessage);
  267.       virtual id_first + id_Week;
  268.     end;
  269.  
  270.   pScoreDialog = ^tScoreDialog;
  271.   tScoreDialog = object(tMyDialog)
  272.     scoreWeek : pMyListBox;
  273.     TeamName  : array [1..MaxTeams] of pStatic;
  274.     ScoreEdit : array [1..MaxTeams] of pNumericEdit;
  275.     constructor init(aParent:pWindowsObject; aName:pChar);
  276.     procedure SetupWindow; virtual;
  277.     procedure BuildSchedule;
  278.     procedure StoreScores;
  279.     procedure Ok(var Msg: TMessage);
  280.                          virtual id_First + id_ok;
  281.     procedure Han